package com.stone.springboot.Test.controller;

import com.stone.springboot.Test.exception.MyBizException;
import com.stone.springboot.Test.pojo.ConfigQuery;
import com.stone.springboot.Test.pojo.ResultBean;
import lombok.SneakyThrows;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLClientInfoException;

/**
 * Created by stone on 2017/6/21.
 */

@RestController
@ConfigurationProperties(prefix = "myProps")
public class TestController {

	private static final Logger _log = LoggerFactory.getLogger(TestController.class);

	@Value("${name}")
	private String name;


	@RequestMapping(value = {"/hello"})
	public String hello() {
		_log.info("123123");
		return String.format("hello,%s", name);
	}

	@RequestMapping(value = {"/testResult"})
	@SneakyThrows(value = {Exception.class})
	public ResultBean<Integer> testResult(ConfigQuery configQuery) {
		return new ResultBean<Integer>(this.sum());
	}

	@SneakyThrows(value = {Exception.class})
	private int sum() {
		int a = 0;
		try {
			a = 1 / 0;
		} catch (Exception e) {
			throw e;
		}
		return a;
	}

}
